package com.hz.score.cus.controller;

import com.hz.score.common.dto.PageDto;
import com.hz.score.cus.dto.CusCommLinkDto;
import com.hz.score.cus.dto.CusIndLinkDto;
import com.hz.score.cus.dto.CusInfoDto;
import com.hz.score.cus.service.CusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "系统用户模块编辑类", description = "编辑系统用户信息及关联企业经营、指标信息")
@Controller
@RequestMapping("/cus")
public class CusController {

    @Resource
    CusService cusService;

    @ApiOperation("分页查询系统用户数据")
    @PostMapping("/page")
    @ResponseBody
    private PageDto<CusInfoDto> pageCus(@RequestBody CusInfoDto cusInfoDto,
                                        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                        @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return cusService.pageCus(cusInfoDto, pageSize, pageNum);
    }

    @ApiOperation("新增系统用户数据")
    @PostMapping("/new")
    @ResponseBody
    private void newCus(@RequestBody CusInfoDto cusInfoDto) {
        cusService.newCus(cusInfoDto);
    }

    @ApiOperation("更新系统用户数据")
    @PostMapping("/update")
    @ResponseBody
    private void updateCus(@RequestBody CusInfoDto cusInfoDto) {
        cusService.updateCus(cusInfoDto);
    }

    @ApiOperation("删除系统用户数据")
    @PostMapping("/delete")
    @ResponseBody
    private void delCus(@RequestBody CusInfoDto cusInfoDto) {
        cusService.delCus(cusInfoDto);
    }

    @ApiOperation("获取系统用户数据")
    @PostMapping("/get")
    @ResponseBody
    private CusInfoDto getCus(@RequestParam(value = "id") Long id) {
        return cusService.getCus(id);
    }

    @ApiOperation("系统用户分页查询关联的企业经营数据")
    @PostMapping("/page/link/comm")
    @ResponseBody
    private PageDto<CusCommLinkDto> pageLinkComm(@RequestBody CusCommLinkDto cusCommLinkDto,
                             @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                             @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return cusService.pageLinkComm(cusCommLinkDto, pageSize, pageNum);
    }

    @ApiOperation("系统用户关联企业经营数据")
    @PostMapping("/link/comm")
    @ResponseBody
    private void linkComm(@RequestBody CusCommLinkDto cusCommLinkDto) {
        cusService.linkComm(cusCommLinkDto);
    }

    @ApiOperation("系统用户取消关联企业经营数据")
    @PostMapping("/unlink/comm")
    @ResponseBody
    private void unlinkComm(@RequestBody CusCommLinkDto cusCommLinkDto) {
        cusService.unlinkComm(cusCommLinkDto);
    }

    @ApiOperation("系统用户分页查询关联的企业指标数据")
    @PostMapping("/page/link/ind")
    @ResponseBody
    private PageDto<CusIndLinkDto> pageLinkComm(@RequestBody CusIndLinkDto cusIndLinkDto,
                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                              @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        return cusService.pageLinkInd(cusIndLinkDto, pageSize, pageNum);
    }

    @ApiOperation("系统用户关联企业指标数据")
    @PostMapping("/link/ind")
    @ResponseBody
    private void linkInd(@RequestBody CusIndLinkDto cusIndLinkDto) {
        cusService.linkInd(cusIndLinkDto);
    }

    @ApiOperation("系统用户取消关联企业经营数据")
    @PostMapping("/unlink/ind")
    @ResponseBody
    private void unlinkInd(@RequestBody CusIndLinkDto cusIndLinkDto) {
        cusService.unlinkInd(cusIndLinkDto);
    }
}
